package com.vdg.fps;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.vdg.R;
import com.vdg.fps.data.FaceBookMessage;
import com.vdg.fps.ulti.Utilities;

public class PrivateMessageActivity extends Activity {
	private Button mBtnClear;
	private Button mBtnSend;
	private EditText mEdtMessage;
	public static final String MESSAGE_KEY = "message";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.private_message_layout);
		initView();
	}

	public void initView() {
		mBtnClear = (Button) findViewById(R.id.btn_clear);
		mBtnSend = (Button) findViewById(R.id.btn_send);
		mEdtMessage = (EditText) findViewById(R.id.edt_message);
		mBtnSend.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				actionSend();
			}
		});
		mBtnClear.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mEdtMessage.setText("");
			}
		});
	}

	private void actionSend() {
		if (mEdtMessage.getText().toString().isEmpty()) {
			Utilities.showToast("The message is required field!", this);
			mEdtMessage.requestFocus();
			return;
		}
		FaceBookMessage msg = new FaceBookMessage();
		msg.setText(mEdtMessage.getText().toString().trim());
		msg.setType(0);
		Intent intent = new Intent();
		intent.putExtra(MESSAGE_KEY, msg);
		setResult(RESULT_OK, intent);
		finish();
	}
}
